home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Square of a floating point number.
- Date: Sat, 13 Apr 96 14:25:57 GMT
- Organization: none
- Message-ID: <829405557snz@genesis.demon.co.uk>
- References: <Dpo0Mn.DEo@ireq.hydro.qc.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <Dpo0Mn.DEo@ireq.hydro.qc.ca> pater@ireq.ca "Ryszard Pater" writes:
-
- >How could I optimize for a speed the function to compute the square
- >of a floating point number? I defined a function as follows:
- >inline float sqr(float a) {return a*a;}
- >or macro version
- >#define sqr(a) ((a)*(a)).
- >If You have a better solution give me a feed back, please.
-
- You're not likely to do better than that for a single square operation.
- But there again a single square operation isn't going to be speed critical.
- Presumably you have an algorithm which performs lots of operation and because
- of that is speed critical. To optimise for speed you should consider how
- how the algorithm as a whole can be optimised.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-